//
//  DCTaskDetailTableViewCell.m
//  JiuyaoMotorcade
//
//  Created by 大橙子 on 2018/11/29.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCTaskDetailTableViewCell.h"
@interface DCTaskDetailTableViewCell ()
@property (nonatomic,strong) UILabel *typeLabel;
@property (nonatomic,strong) UILabel *VINLabel;
@property (nonatomic,strong) UILabel *colorLabel;
@end
@implementation DCTaskDetailTableViewCell
+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *CellID = @"Cell";
    DCTaskDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    if (cell == nil) {
        cell = [[DCTaskDetailTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI
{
    self.typeLabel = [self getLabelWithFont:14 textAlignment:NSTextAlignmentCenter];
    [self addSubview:self.typeLabel];
    
    self.VINLabel = [self getLabelWithFont:14 textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.VINLabel];
    
    self.colorLabel = [self getLabelWithFont:14 textAlignment:NSTextAlignmentCenter];
    [self addSubview:self.colorLabel];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.VINLabel.frame = CGRectMake(10, 0, self.width/2, self.height);
    self.typeLabel.frame = CGRectMake(self.VINLabel.right, 0, self.width/4, self.height);
    self.colorLabel.frame = CGRectMake(self.typeLabel.right, 0, self.typeLabel.width, self.height);
}

-(void)setModel:(DCTaskDetailCarArray *)model
{
    _model = model;
    self.VINLabel.text = model.vIN;
    self.typeLabel.text = model.carType;
    self.colorLabel.text = model.color;
}
-(UILabel *)getLabelWithFont:(NSInteger)font textAlignment:(NSTextAlignment)textAlignment
{
    UILabel *label = [[UILabel alloc]init];
    label.font = FONT(font);
    label.textAlignment = textAlignment;
    return label;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
